package com.yitiao.listener;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;

/**
 * @author libiao
 * 配置文件 redis.windows.conf 中设置键空间通知事件为Ex
 * notify-keyspace-events Ex
 */
public class RedisMessageListener implements MessageListener {

    /**
     * Redis 事件监听回调
     */
    @Override
    public void onMessage(Message message, byte[] pattern) {
        byte[] body = message.getBody();

        String expiredKey = new String(body);

        System.out.println("监听到已过期的key：" + expiredKey);
//        TODO:监听到过期事件回调
    }
}
